package com.wingy.test;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class RecyclerViewAdpter extends RecyclerView.Adapter<RecyclerViewAdpter.ViewHolder> {

    private List<LifeDiary> mLifedairyList;

    public RecyclerViewAdpter(List<LifeDiary>lifediaryList) {mLifedairyList = lifediaryList;}

    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView titleView;
        TextView dateView;

        public ViewHolder(View view) {
            super(view);
            titleView = (TextView) view.findViewById(R.id.rec_item_lifediary_title);
            dateView = (TextView) view.findViewById(R.id.rec_item_date);
        }
    }

    public ViewHolder onCreateViewHolder(ViewGroup parrent, int viewType) {
        View view = LayoutInflater.from(parrent.getContext()).inflate(R.layout.recycler_item,parrent,false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    public void onBindViewHolder(ViewHolder holder, int position) {
        LifeDiary lifeDiary = mLifedairyList.get(position);
        holder.titleView.setText(lifeDiary.getTitle());
        holder.dateView.setText(lifeDiary.getDate());
    }

    public int getItemCount() {return mLifedairyList.size();}

}
